package com.android.cricle;

import java.util.Random;

import android.app.Activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;

public class CircleActivity extends Activity {
  /** Called when the activity is first created. */
  Circleview view;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    FrameLayout layout = (FrameLayout) findViewById(R.id.Lottery);
    int screnWidth = getWindowManager().getDefaultDisplay().getWidth();

    final Random random = new Random();
    final Circleview claert = new Circleview(this, screnWidth);
    layout.addView(claert,
        new LayoutParams(LayoutParams.FILL_PARENT, DensityUtil.dip2px(this, 300)));

    findViewById(R.id.begin_btn).setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        int place = random.nextInt(7);
        claert.setStopPlace(place);
        claert.setStopRoter(false);
      }
    });
    findViewById(R.id.end_btn).setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        claert.setStopRoter(true);
      }
    });
  }
}